import React from 'react';
import { Card, Table, Divider ,Modal, Button, Form, Input,InputNumber, Radio, DatePicker,Select, Icon, Upload, message ,Pagination,Spin} from 'antd';
import moment from 'moment';
import { NavLink} from 'react-router-dom';
import ResizeableTitle from './../../../utils/resizeableTitle';
import TableForm from './../../../components/TableForm';
import Utils from './../../../utils/utils';
import './../../../style/style.css';
import './index.less';
import Axios from "../../../axios";
const FormItem = Form.Item;
const RadioGroup = Radio.Group;
const Option = Select.Option;
const TextArea = Input.TextArea;

export default class JobImpower extends React.Component {
    state = {
        columns: [{
            title: '岗位名称',
            dataIndex: 'jobsName',
            width: 200,
        }, {
            title: '用户名称',
            dataIndex: 'userName',
            width: 200,
        }, {
            title: '授权开始时间',
            dataIndex: 'beginTime',
            width: 200,
        }, {
            title: '授权结束时间',
            dataIndex: 'endTime',
            width: 200,
        },{
            title: '授权操作',
            dataIndex: 'authOperation',
            width: 200,
        }, {
            title: '授权设备',
            dataIndex: 'authEquipment',
            width: 200,
        }, {
            title: '用户职称',
            dataIndex: 'jobTitle',
            width: 150,
        },{
            title: '用户专业',
            dataIndex: 'specialty',
            width: 150,
        },{
            title: '备注',
            dataIndex: 'remark',
            width: 150,
        },{
            title: '状态',
            dataIndex: 'state',
            width: 100,
            render: (text, record,index) => (
                <span>
                    {record.state == "VALID" ? <span className="txt-success">审批通过</span> : ''}
                    {record.state == "INVALID" ? <span className="txt-danger">审批拒绝</span> : ''}
                    {record.state == "DISABLE" ? <span className="txt-danger">禁用的</span> : ''}
                    {record.state == "DELETE" ? <span className="txt-danger">删除的</span> : ''}
                    {record.state == "WAIT_AUDIT" ? <span className="txt-danger">待审核</span> : ''}
                    {record.state == "UNDER_REVIEW" ? <span className="txt-danger">审核中</span> : ''}
                </span>
            )
        },{
            title: '操作',
            key: 'action',
            render: (text, record,index) => (
                <span>
                    {record.state == "WAIT_AUDIT" ?
                        <span>
                            <a onClick={() => this.handleUpdate(record)} className="btn-txt-primary">修改</a>
                            <Divider type="vertical" />
                            <a onClick={() => this.handleDel(record)} className="btn-txt-danger">删除</a>
                        </span>
                        : ''
                    }
                    {record.state == "INVALID" ?
                        <span>
                            <a onClick={() => this.handleDel(record)} className="btn-txt-danger">删除</a>
                        </span>
                        : ''
                    }
                    {record.state == "VALID" ?
                        <span>
                            <a onClick={() => this.handleCancleImpower(record)} className="btn-txt-danger">取消授权</a>
                        </span>
                        : ''
                    }
                </span>
            ),
        }],
        createImpowerModal:{
            visible: false,
            confirmLoading: false,
        },
        updateImpowerModal:{
            visible: false,
            confirmLoading: false,
        },
        createImpowerApprovalModal:{
            visible: false,
            confirmLoading: false,
        },
        createRootsRecordModal:{
            visible: false,
            confirmLoading: false,
        },
    };
    initParams={
        max:10,
        keywords:'',
        page:1,
    }
    componentWillMount(){
        let params = Utils.FilterParam(this.initParams); //过滤掉为空的参数
        this.listRequest(params);//获取列表数据
        this.jobsRequest();//查询所有有效岗位
        this.userRequest();//查询所有用户
    }
    //搜索
    handleFilter = (fieldsValue)=>{
        const values = {
            ...fieldsValue,
        };
        let params = {
            ...this.initParams,
            ...values,
            page:1,
        }
        params = Utils.FilterParam(params); //过滤掉为空的参数
        this.listRequest(params);
    }
    // 添加用户岗位授权
    handleCreateImpower = ()=>{
        this.setState({
            createImpowerModal:{
                ...this.state.createImpowerModal,
                visible:true
            }
        })
    }
    //添加用户岗位授权 确定
    handleCreateImpowerSubmit = ()=>{
        const _form = this.createImpowerForm.props.form;
        _form.validateFields((err, values) => {
            console.log(values);
            if (err) {
                return;
            }
            values.jobsId = values.jobsIdName.key;
            values.jobsName = values.jobsIdName.label;
            values.userId = values.userIdName.key;
            values.userName = values.userIdName.label;
            values.beginTime = moment(values.beginTime).format("YYYY-MM-DD HH:mm:ss");
            values.endTime = moment(values.endTime).format("YYYY-MM-DD HH:mm:ss");
            delete values.jobsIdName;
            delete values.userIdName;
            let param = Utils.FilterParam(values);
            console.log(param)
            this.createImpowerRequest(param);
        });
    }
    //修改用户岗位授权
    handleUpdate = (record)=>{
        this.setState({
            updateImpowerModal:{
                ...this.state.updateImpowerModal,
                visible:true,
                record
            }
        })
    }
    //修改用户岗位授权 确定
    handleUpdateImpowerSubmit = ()=>{
        const _form = this.updateImpowerForm.props.form;
        _form.validateFields((err, values) => {
            console.log(values);
            if (err) {
                return;
            }
            console.log(values);
            values.jobsId = values.jobsIdName.key;
            values.jobsName = values.jobsIdName.label;
            values.userId = values.userIdName.key;
            values.userName = values.userIdName.label;
            values.beginTime = moment(values.beginTime).format("YYYY-MM-DD HH:mm:ss");
            values.endTime = moment(values.endTime).format("YYYY-MM-DD HH:mm:ss");
            delete values.jobsIdName;
            delete values.userIdName;
            let param = Utils.FilterParam(values);
            console.log(param)
            this.updateImpowerRequest(param);
        });
    }
    //删除用户岗位授权
    handleDel = (record)=>{
        Modal.confirm({
            title: '确认删除？',
            content: <div>
                <div>删除后数据不可恢复！</div>
                <div className="txt-danger">确认删除？</div>
            </div>,
            okText:'确认',
            cancelText:'取消',
            onOk:()=>{
                let params = {
                    id:record.id
                }
                this.delRequest(params)
            }
        })
    }
    //取消用户岗位授权
    handleCancleImpower = (record)=>{
        Modal.confirm({
            title: '确认用户岗位授权？',
            content: <div>
                <div>取消授权后数据不可恢复！</div>
                <div className="txt-danger">确认取消授权？</div>
            </div>,
            okText:'确认',
            cancelText:'取消',
            onOk:()=>{
                let params = {
                    id:record.id
                }
                this.cancleImpowerRequest(params);
            }
        })
    }

    //批量选择 提交用户岗位授权审批
    handleBatchCheck = ()=>{
        const selectedRowKeys =this.state.selectedRowKeys;
        const selectedRows =this.state.selectedRows;
        console.log(selectedRowKeys)
        console.log(selectedRows)
        if (!selectedRowKeys||!selectedRowKeys.length) {
            Modal.error({
                title: '提示信息',
                content: '请先从列表选择用户岗位授权，再提交用户岗位授权审批！',
                //okText:'确认',
                onOk:()=>{
                }
            })
        }else {
            this.setState({
                selectedRows,
                selectedRowKeys
            })
            this.setState({
                createImpowerApprovalModal:{
                    ...this.state.createImpowerApprovalModal,
                    visible:true
                }
            })
        }

    }
    //批量选择 提交用户岗位授权审批 确定提交
    handleCreatImpowerApprovalSubmit = ()=>{
        const _form = this.creatImpowerApprovalForm.props.form;
        _form.validateFields((err, values) => {
            console.log(values);
            if (err) {
                return;
            }
            console.log(values);
            values.uaIds = JSON.stringify(values.uaIds);
            let param = Utils.FilterParam(values);
            console.log(param)
            this.creatImpowerApprovalRequest(param);
        });
    }
    /*查询用户岗位授权列表请求*/
    listRequest = (params)=>{
        let _this = this;
        this.setState({
            loading:true,
            loadingTxt:'加载中...'
        })
        Axios.dataRequest({
            block:'/hr',
            url:'/userAuthorization',
            params:params,
        }).then((data)=>{
            console.log(data)
            let page = data.page;
            let dataSource = data.data;
            dataSource.map((item)=>{
                item.key = item.id;
                return item;
            })
            this.setState({
                loading:false,
                dataSource,
                pagination: Utils.pagination(page, (current) => {
                    _this.initParams.page = current;
                    let params = this.initParams;
                    _this.listRequest(params);
                },(current,pageSize) =>{
                    _this.initParams.page = current;
                    _this.initParams.max = pageSize;
                    let params = Utils.FilterParam(this.initParams); //过滤掉为空的参数
                    _this.listRequest(params);
                })
            })
        }).catch((error)=>{
            this.setState({ loading:false })
            console.log(error);
        })
    }
    /*添加用户岗位授权请求*/
    createImpowerRequest = (params)=>{
        this.setState({
            createImpowerModal:{
                ...this.state.createImpowerModal,
                confirmLoading: true,
            }
        })
        Axios.formRequest({
            block:'/hr',
            url:'/userAuthorization',
            params:params,
        }).then((data)=>{
            console.log(data)
            this.setState({
                createImpowerModal:{
                    ...this.state.createImpowerModal,
                    visible: false,
                }
            },()=>{
                message.success('添加用户岗位授权成功！',2,()=>{
                    window.location.reload()
                });
            })
        }).catch((error)=>{
            console.log(error);
            this.setState({
                createImpowerModal:{
                    ...this.state.createImpowerModal,
                    confirmLoading: false,
                }
            })
        })
    }
    /*修改用户岗位授权请求*/
    updateImpowerRequest = (params)=>{
        this.setState({
            updateImpowerModal:{
                ...this.state.updateImpowerModal,
                confirmLoading: true,
            }
        })
        Axios.formPutRequest({
            block:'/hr',
            url:'/userAuthorization',
            params:params,
        }).then((data)=>{
            console.log(data)
            this.setState({
                updateImpowerModal:{
                    ...this.state.updateImpowerModal,
                    visible: false,
                }
            },()=>{
                message.success('修改用户岗位授权成功！',2,()=>{
                    //window.location.reload()
                    let params = Utils.FilterParam(params); //过滤掉为空的参数
                    this.listRequest(params);
                });
            })
        }).catch((error)=>{
            console.log(error);
            this.setState({
                updateImpowerModal:{
                    ...this.state.updateImpowerModal,
                    confirmLoading: false,
                }
            })
        })
    }
    /*删除请求*/
    delRequest = (params)=>{
        this.setState({
            loading:true,
            loadingTxt:'删除中...'
        })
        Axios.delRequest({
            block:'/hr',
            url:'/userAuthorization',
            params:params,
        }).then((data)=>{
            //console.log(data);
            this.setState({ loading:false })
            message.success('删除成功！',2,()=>{
                let params = Utils.FilterParam(params); //过滤掉为空的参数
                this.listRequest(params);
            });
        }).catch((error)=>{
            this.setState({ loading:false })
            console.log(error);
        })
    }
    /*取消岗位授权请求*/
    cancleImpowerRequest = (params)=>{
        this.setState({
            loading:true,
            loadingTxt:'岗位授权取消中...'
        })
        Axios.formRequest({
            block:'/hr',
            url:'/userAuthorization/cancelAuth',
            params:params,
        }).then((data)=>{
            //console.log(data);
            this.setState({ loading:false })
            message.success('岗位授权取消成功！',2,()=>{
                let params = Utils.FilterParam(params); //过滤掉为空的参数
                this.listRequest(params);
            });
        }).catch((error)=>{
            this.setState({ loading:false })
            console.log(error);
        })
    }
    /*用户岗位授权审批*/
    creatImpowerApprovalRequest = (params)=>{
        this.setState({
            createImpowerApprovalModal:{
                ...this.state.createImpowerApprovalModal,
                confirmLoading: true,
            }
        })
        Axios.formRequest({
            block:'/hr',
            url:'/userAuthorization/userAuthorizationApply',
            params:params,
        }).then((data)=>{
            console.log(data)
            this.setState({
                createImpowerApprovalModal:{
                    ...this.state.createImpowerApprovalModal,
                    visible: false,
                }
            },()=>{
                message.success('提交用户岗位授权审批成功，请到审批记录查看！',2,()=>{
                    window.location.reload()
                   /* let params = Utils.FilterParam(params); //过滤掉为空的参数
                    this.listRequest(params);*/
                });
            })
        }).catch((error)=>{
            console.log(error);
            this.setState({
                createImpowerApprovalModal:{
                    ...this.state.createImpowerApprovalModal,
                    confirmLoading: false,
                }
            })
        })
    }
    /*所有有效岗位请求*/
    jobsRequest = ()=>{
        Axios.dataRequest({
            block:'/hr',
            url:'/jobs/valid',
            params:"",
        }).then((data)=>{
            console.log(data)
            let jobs = data.data;
            this.setState({
                jobs,
            })
        }).catch((error)=>{
            console.log(error);
        })
    }
    /*所有用户请求*/
    userRequest = ()=>{
        Axios.dataRequest({
            block:'/hr',
            url:'/user/allUserSmallInfos',
            params:"",
        }).then((data)=>{
            console.log(data)
            let users = data.data;
            /*id name userNo*/
            this.setState({
                users,
            })
        }).catch((error)=>{
            console.log(error);
        })
    }
    //伸缩列
    components = {
        header: {
            cell:ResizeableTitle
        },
    };
    handleResize = index => (e, { size }) => {
        this.setState(({ columns }) => {
            const nextColumns = [...columns];
            nextColumns[index] = {
                ...nextColumns[index],
                width: size.width,
            };
            return { columns: nextColumns };
        });
    };
    render() {
        //伸缩列
        const columns = this.state.columns.map((col, index) => ({
            ...col,
            onHeaderCell: column => ({
                width: column.width,
                onResize: this.handleResize(index),
            }),
        }));
        //复选框属性
        const rowSelection = {
            onChange: (selectedRowKeys, selectedRows) => {
                // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
                this.setState({
                    selectedRowKeys,
                    selectedRows
                })
            },
            //选择框的默认属性配置
            getCheckboxProps: record => ({
                disabled: record.state === 'VALID' || record.state==='INVALID'|| record.state==='DISABLE'|| record.state==='DELETE'|| record.state==='UNDER_REVIEW',
            }),
        };
        return (
            <Spin spinning={this.state.loading} size="large" tip={this.state.loadingTxt}>
                <div className="tab-list-box">
                    <Card title="用户岗位授权列表">
                        <div className="filter-box" style={{marginBottom:15}}>
                            <FilterForm filterSubmit={(fieldsValue)=>{this.handleFilter(fieldsValue)}}/>
                            <div>
                                <NavLink className="btn-txt-primary" to={'/organMember/user/jobImpApprovalRecord'} style={{marginRight:15}}>用户岗位授权审批记录</NavLink>
                                <Button type="primary" icon="clock-circle" onClick={this.handleBatchCheck} style={{marginRight:15}}>用户岗位授权审批</Button>
                                <Button type="primary" icon="plus" onClick={this.handleCreateImpower}>添加用户岗位授权</Button>
                            </div>
                        </div>
                        <Table
                            bordered
                            rowSelection={rowSelection}
                            components={this.components}
                            columns={columns}
                            dataSource={this.state.dataSource}
                            pagination={this.state.pagination}
                        />
                    </Card>
                    <Modal title="添加用户岗位授权"
                           width={850}
                           visible={this.state.createImpowerModal.visible}
                           onOk={this.handleCreateImpowerSubmit}
                           okText="确定"
                           confirmLoading={this.state.createImpowerModal.confirmLoading}
                           onCancel={()=>{
                               this.setState({
                                   createImpowerModal:{
                                       visible:false
                                   }
                               })
                           }}
                    >
                        <CreateImpowerForm
                            jobs={this.state.jobs}
                            users={this.state.users}
                            wrappedComponentRef={(createImpowerForm)=>{this.createImpowerForm = createImpowerForm;}}/>
                    </Modal>
                    <Modal title="修改用户岗位授权"
                           width={850}
                           visible={this.state.updateImpowerModal.visible}
                           onOk={this.handleUpdateImpowerSubmit}
                           okText="确定"
                           confirmLoading={this.state.updateImpowerModal.confirmLoading}
                           onCancel={()=>{
                               this.setState({
                                   updateImpowerModal:{
                                       visible:false
                                   }
                               })
                           }}
                    >
                        <UpdateImpowerForm
                            jobs={this.state.jobs}
                            users={this.state.users}
                            record={this.state.updateImpowerModal.record}
                            wrappedComponentRef={(updateImpowerForm)=>{this.updateImpowerForm = updateImpowerForm;}}/>
                    </Modal>
                    <Modal title="用户岗位授权审批"
                           visible={this.state.createImpowerApprovalModal.visible}
                           onOk={this.handleCreatImpowerApprovalSubmit}
                           okText="提交"
                           confirmLoading={this.state.createImpowerApprovalModal.confirmLoading}
                           onCancel={()=>{
                               this.setState({
                                   createImpowerApprovalModal:{
                                       visible:false
                                   }
                               })
                           }}
                    >
                        <CreatImpowerApprovalForm
                            selectedRowKeys={this.state.selectedRowKeys}
                            wrappedComponentRef={(creatImpowerApprovalForm)=>{this.creatImpowerApprovalForm = creatImpowerApprovalForm;}}/>
                    </Modal>
                </div>
            </Spin>
        );
    }
}

//添加用户岗位授权表单
class CreateImpowerForm extends React.Component{
    handleJobsChange = (e)=>{
        let selJobsId = e.key;
        let jobs = this.props.jobs||[];
        jobs.map((item)=>{
            if (selJobsId==item.id){
                this.props.form.setFieldsValue({
                    authOperation:item.authOperation,
                    authEquipment:item.authEquipment,
                })
            }
        })
    }
    render(){
        const { getFieldDecorator } = this.props.form;
        const formItemLayout = {
            labelCol: {span: 7},
            wrapperCol: {span: 16}
        };
        const jobs = this.props.jobs||[];
        const users = this.props.users||[];
        const jobsOptions = jobs.map((item,index)=>{
            return <Option key={index} value={item.id}>{item.name}</Option>
        })
        const usersOptions = users.map((item,index)=>{
            return <Option key={index} value={item.id}>{item.name}</Option>
        })
        let nowDate = new Date();//获取系统当前时间
        return (
            <div className="layout-form">
                <Form className="left-div">
                    <FormItem label="用户" {...formItemLayout}>
                        {
                            getFieldDecorator('userIdName',{
                                rules: [{ required: true, message: '请选择用户!' }],
                            })(
                                <Select
                                    labelInValue
                                    placeholder="请选择用户"
                                    style={{ minWidth: 160 }}
                                    showSearch
                                    optionFilterProp="children"
                                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                >
                                    {usersOptions}
                                </Select>
                            )
                        }
                    </FormItem>
                    <FormItem label="岗位" {...formItemLayout}>
                        {
                            getFieldDecorator('jobsIdName',{
                                rules: [{ required: true, message: '请选择岗位!' }],
                            })(
                                <Select
                                    placeholder="请选择岗位"
                                    labelInValue
                                    style={{ minWidth: 160 }}
                                    showSearch
                                    onChange={this.handleJobsChange}
                                    optionFilterProp="children"
                                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                >
                                    {jobsOptions}
                                </Select>
                            )
                        }
                    </FormItem>
                    <FormItem label="授权操作" {...formItemLayout}>
                        {
                            getFieldDecorator('authOperation',{
                            })(
                                <TextArea placeholder="授权操作" disabled={true} autosize/>
                            )
                        }
                    </FormItem>
                    <FormItem label="授权设备" {...formItemLayout}>
                        {
                            getFieldDecorator('authEquipment',{
                            })(
                                <TextArea placeholder="授权设备" disabled={true} autosize/>
                            )
                        }
                    </FormItem>
                    <FormItem label="授权开始时间" {...formItemLayout}>
                        {
                            getFieldDecorator('beginTime', {
                                rules: [{ required: true, message: '请选择授权开始时间!' }],
                                initialValue:moment(nowDate)
                            })(
                                <DatePicker format="YYYY-MM-DD HH:mm:ss" showTime={true} placeholder="授权开始时间"/>
                            )
                        }
                    </FormItem>
                </Form>
                <Form className="right-div">
                    <FormItem label="授权结束时间" {...formItemLayout}>
                        {
                            getFieldDecorator('endTime', {
                                rules: [{ required: true, message: '请选择授权结束时间!' }],
                            })(
                                <DatePicker format="YYYY-MM-DD HH:mm:ss" showTime={true} placeholder="授权结束时间"/>
                            )
                        }
                    </FormItem>
                    <FormItem label="用户职称" {...formItemLayout}>
                        {
                            getFieldDecorator('jobTitle',{
                                rules: [{ required: true, message: '请填写用户职称!' }],
                            })(
                                <Input type="text" placeholder="用户职称"/>
                            )
                        }
                    </FormItem>
                    <FormItem label="用户专业" {...formItemLayout}>
                        {
                            getFieldDecorator('specialty',{
                                rules: [{ required: true, message: '请填写用户专业!' }],
                            })(
                                <Input type="text" placeholder="用户专业"/>
                            )
                        }
                    </FormItem>
                    <FormItem label="备注" {...formItemLayout}>
                        {
                            getFieldDecorator('remark',{
                            })(
                                <TextArea placeholder="备注" autosize/>
                            )
                        }
                    </FormItem>
                </Form>
            </div>
        );
    }
}
CreateImpowerForm = Form.create({})(CreateImpowerForm);
//修改用户岗位授权表单
class UpdateImpowerForm extends React.Component{
    handleJobsChange = (e)=>{
        let selJobsId = e.key;
        let jobs = this.props.jobs||[];
        jobs.map((item)=>{
            if (selJobsId==item.id){
                this.props.form.setFieldsValue({
                    authOperation:item.authOperation,
                    authEquipment:item.authEquipment,
                })
            }
        })
    }
    render(){
        const { getFieldDecorator } = this.props.form;
        const formItemLayout = {
            labelCol: {span: 7},
            wrapperCol: {span: 16}
        };
        const record = this.props.record||{};
        const jobs = this.props.jobs||[];
        const users = this.props.users||[];
        const jobsOptions = jobs.map((item,index)=>{
            return <Option key={index} value={item.id}>{item.name}</Option>
        })
        const usersOptions = users.map((item,index)=>{
            return <Option key={index} value={item.id}>{item.name}</Option>
        })
        return (
            <div className="layout-form">
                <Form className="left-div">
                    <FormItem label="id" {...formItemLayout}>
                        {
                            getFieldDecorator('id',{
                                initialValue:record.id
                            })(
                                <Input type="text" placeholder="id"/>
                            )
                        }
                    </FormItem>
                    <FormItem label="用户" {...formItemLayout}>
                        {
                            getFieldDecorator('userIdName',{
                                rules: [{ required: true, message: '请选择用户!' }],
                                initialValue:{key:record.userId,label:record.userName}
                            })(
                                <Select
                                    labelInValue
                                    placeholder="请选择用户"
                                    style={{ minWidth: 160 }}
                                    showSearch
                                    optionFilterProp="children"
                                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                >
                                    {usersOptions}
                                </Select>
                            )
                        }
                    </FormItem>
                    <FormItem label="岗位" {...formItemLayout}>
                        {
                            getFieldDecorator('jobsIdName',{
                                rules: [{ required: true, message: '请选择岗位!' }],
                                initialValue:{key:record.jobsId,label:record.jobsName}
                            })(
                                <Select
                                    placeholder="请选择岗位"
                                    labelInValue
                                    style={{ minWidth: 160 }}
                                    showSearch
                                    onChange={this.handleJobsChange}
                                    optionFilterProp="children"
                                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                >
                                    {jobsOptions}
                                </Select>
                            )
                        }
                    </FormItem>
                    <FormItem label="授权操作" {...formItemLayout}>
                        {
                            getFieldDecorator('authOperation',{
                                initialValue:record.authOperation
                            })(
                                <TextArea placeholder="授权操作" disabled={true} autosize/>
                            )
                        }
                    </FormItem>
                    <FormItem label="授权设备" {...formItemLayout}>
                        {
                            getFieldDecorator('authEquipment',{
                                initialValue:record.authEquipment
                            })(
                                <TextArea placeholder="授权设备" disabled={true} autosize/>
                            )
                        }
                    </FormItem>
                    <FormItem label="授权开始时间" {...formItemLayout}>
                        {
                            getFieldDecorator('beginTime', {
                                rules: [{ required: true, message: '请选择授权开始时间!' }],
                                initialValue:moment(record.beginTime)
                            })(
                                <DatePicker format="YYYY-MM-DD HH:mm:ss" showTime={true} placeholder="授权开始时间"/>
                            )
                        }
                    </FormItem>
                </Form>
                <Form className="right-div">
                    <FormItem label="授权结束时间" {...formItemLayout}>
                        {
                            getFieldDecorator('endTime', {
                                rules: [{ required: true, message: '请选择授权结束时间!' }],
                                initialValue:moment(record.endTime)
                            })(
                                <DatePicker format="YYYY-MM-DD HH:mm:ss" showTime={true} placeholder="授权结束时间"/>
                            )
                        }
                    </FormItem>
                    <FormItem label="用户职称" {...formItemLayout}>
                        {
                            getFieldDecorator('jobTitle',{
                                rules: [{ required: true, message: '请填写用户职称!' }],
                                initialValue:record.jobTitle
                            })(
                                <Input type="text" placeholder="用户职称"/>
                            )
                        }
                    </FormItem>
                    <FormItem label="用户专业" {...formItemLayout}>
                        {
                            getFieldDecorator('specialty',{
                                rules: [{ required: true, message: '请填写用户专业!' }],
                                initialValue:record.specialty
                            })(
                                <Input type="text" placeholder="用户专业"/>
                            )
                        }
                    </FormItem>
                    <FormItem label="备注" {...formItemLayout}>
                        {
                            getFieldDecorator('remark',{
                                initialValue:record.remark
                            })(
                                <TextArea placeholder="备注" autosize/>
                            )
                        }
                    </FormItem>
                </Form>
            </div>
        );
    }
}
UpdateImpowerForm = Form.create({})(UpdateImpowerForm);
//用户岗位授权审批
class CreatImpowerApprovalForm extends React.Component{
    state = {}
    componentWillMount(){
        this.getNoRequest();
    }
    /*获取用户岗位授权审批编号*/
    getNoRequest = ()=>{
        let params = {
            key:'jobs_impower_no'
        }
        this.setState({
            loading:true,
            loadingTxt:'获取用户岗位授权审批编号中...'
        })
        Axios.dataRequest({
            block:'/setting',
            url:'/objectNo/nextNo',
            params:params,
        }).then((data)=>{
            let No = data.data;
            this.setState({
                loading:false,
                No
            })
        }).catch((error)=>{
            this.setState({ loading:false })
            console.log(error);
        })
    }
    render(){
        const { getFieldDecorator } = this.props.form;
        const formItemLayout = {
            labelCol: {span: 6},
            wrapperCol: {span: 16}
        };
        const No = this.state.No||"";
        const selectedRowKeys = this.props.selectedRowKeys;
        return (
            <Spin spinning={this.state.loading} size="large" tip={this.state.loadingTxt}>
                <Form>
                    <FormItem label="用户岗位授权审批编号列表" {...formItemLayout} style={{display:"none"}}>
                        {
                            getFieldDecorator('uaIds',{
                                initialValue:selectedRowKeys
                            })(
                                <Input type="text" placeholder="用户岗位授权审批"/>
                            )
                        }
                    </FormItem>
                    <FormItem label="标题" {...formItemLayout}>
                        {
                            getFieldDecorator('title',{
                                rules: [{ required: true, message: '请填写标题!' }],
                            })(
                                <Input type="text" placeholder="标题"/>
                            )
                        }
                    </FormItem>
                    <FormItem label="审批编号" {...formItemLayout}>
                        {
                            getFieldDecorator('no',{
                                rules: [{ required: true, message: '请填写审批编号!' }],
                                initialValue:No
                            })(
                                <Input type="text" placeholder="审批编号"/>
                            )
                        }
                    </FormItem>
                </Form>
            </Spin>
        );
    }
}
CreatImpowerApprovalForm = Form.create({})(CreatImpowerApprovalForm);

//搜索表单
class FilterForm extends React.Component{
    handleFilterSubmit = ()=>{
        let fieldsValue = this.props.form.getFieldsValue();
        this.props.filterSubmit(fieldsValue);
    }
    //重置
    reset = ()=>{
        this.props.form.resetFields();
    }
    render(){
        const { getFieldDecorator } = this.props.form;
        return (
            <Form layout="inline">
                <FormItem label="关键字">
                    {
                        getFieldDecorator('keywords',{
                        })(
                            <Input type="text" placeholder="关键字"/>
                        )
                    }
                </FormItem>
                <FormItem>
                    <Button type="primary" style={{margin:'0 20px'}} onClick={this.handleFilterSubmit}>查询</Button>
                    <Button onClick={this.reset}>重置</Button>
                </FormItem>
            </Form>
        );
    }
}
FilterForm = Form.create({})(FilterForm);

